<template>
  <div class="Page">
    <div class="left">4</div>
    <i class="iconfont icon-rocket"></i>
    <i class="iconfont icon-weixiu1"></i>
    <div class="right">4</div>
    <div class="text"><span>{{ text2 }}</span></div>
  </div>
</template>

<script setup>
import { onMounted, ref } from 'vue'

const text = "Page Not Found !"
const text2 = ref('')
onMounted(() => {
  initText()
})

const initText = () => {
  for (let i = 0; i < text.length + 1; i++) {
      (function (time) {   // 匿名函数的形参
        setTimeout(function () {
          text2.value = text.slice(0, i)
        }, 700 * time)	// 还是每秒执行一次，不是累加的
      })(i)
  }
}
</script>

<style lang="less" scoped>
.Page {
  background-color: rgb(31, 30, 85);
  width: 100vw;
  height: 100vh;
  position: relative;
  user-select: none;

  .left {
    font-size: 28vw;
    color: #fff;
    position: absolute;
    left: 18%;
  }

  .right {
    font-size: 28vw;
    color: #fff;
    position: absolute;
    left: 82%;
    transform: translate(-100%);
  }

  .text {
    position: absolute;
    color: #888;
    top: 80%;
    font-size: 2vw;
    width: 64%;
    left: 18%;

    span {
      padding-right: 2px;
      position: relative;

      &::after {
        content: "";
        width: 2px;
        height: 100%;
        position: absolute;
        right: 0;
        top: 0;
        background-color: #fff;
        animation: blink 1s linear infinite;
      }
    }

    @keyframes blink {

      0%,
      49% {
        opacity: 0;
      }

      50%,
      100% {
        opacity: 1;
      }
    }

  }

  .icon-rocket {
    width: 16vw;
    height: 16vw;
    line-height: 16vw;
    padding: 3vw;
    text-align: center;
    font-size: 12vw;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border: 2vw solid rgb(42, 41, 116);
    border-radius: 50%;
    background-color: rgb(62, 60, 155);
    color: pink;
    animation: shake 1s infinite linear;
  }

  @keyframes shake {
    0% {
      transform: translate(-50%, -50%) rotate(0);
    }

    25% {
      transform: translate(-50%, -50%) rotate(1deg);
    }

    50% {
      transform: translate(-50%, -50%) rotate(0);
    }

    75% {
      transform: translate(-50%, -50%) rotate(0);
    }

    100% {
      transform: translate(-50%, -50%) rotate(0deg);
    }
  }

  .icon-weixiu1 {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: rgb(118, 72, 147);
    font-size: 3.5vw;
    animation: slidein 2.5s infinite;
  }

  @keyframes slidein {
    0% {
      opacity: 0;
    }

    50% {
      opacity: 1;
    }

    100% {
      opacity: 0;
    }
  }
}
</style>